<!DOCTYPE html>
<!--
Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
-->
<html>
<head>
  <meta charset="utf-8">
  <title>CKEditor Sample</title>
  <script src="ckeditor/ckeditor.js"></script>
  <script src="ckeditor/samples/js/sample.js"></script>
  <link rel="stylesheet" href="ckeditor/samples/css/samples.css">
  <link rel="stylesheet" href="ckeditor/samples/toolbarconfigurator/lib/codemirror/neo.css">
</head>
<body style="overflow: hidden" ondragover="drop(event)" ondrop="drop(event)">
<div id="editor" style="background: red"></div>
<script>
  if (window.top !== window.self) {
    let customConfig = '';

    if (window.parent.configPath) {
      customConfig = 'file://' + window.parent.configPath
    } else {
      customConfig = '/static/ckeditor_config.js'
    }

    CKEDITOR.replace('editor', {
      customConfig: customConfig
    });
    CKEDITOR.iFrameWindow = window;
    var evt = document.createEvent("CustomEvent");
    evt.initCustomEvent("initEditor", false, false, window);
    window.parent.dispatchEvent(evt);
  } else {
    initSample();
  }


  function drop(ev) {
    ev.preventDefault();
    ev.stopPropagation();
    ev.dataTransfer.dropEffect = "copy";
    if (ev.type === 'dragover') return;
    let _window = window.top !== window.self ? window.top : window;
    let dataTransfer = ev.dataTransfer;
    let dragEvent = new DragEvent('drop', {dataTransfer});
    _window.top.dispatchEvent(dragEvent);
  }
</script>

</body>
</html>
